package com.lagou.edu.mvcframework.pojo;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;

/**
 * hander实体类
 * @author 陶肖寅
 * @version V1.0
 * @Package com.lagou.edu.mvcframework.pojo
 * @date 2020-02-01 12:28
 * @Copyright © 2020-2021 城云科技(中国)有限公司
 */
public class Handler {
    //执行的方法
    private Method method;
    /**
     * controller
     */
    private Object controller;

    private Pattern pattern; //spring中url支持正则
    //存储参数顺序，为了参数绑定，key是参数名，value是第几个参数<name,2>
    private Map<String,Integer> paramIndexMapping;

    public Handler() {
        this.paramIndexMapping = new HashMap<>();
    }

    public Handler(Method method, Object controller, Pattern pattern) {
        this.method = method;
        this.controller = controller;
        this.pattern = pattern;
        this.paramIndexMapping = new HashMap<>();
    }

    public Method getMethod() {
        return method;
    }

    public void setMethod(Method method) {
        this.method = method;
    }

    public Object getController() {
        return controller;
    }

    public void setController(Object controller) {
        this.controller = controller;
    }

    public Pattern getPattern() {
        return pattern;
    }

    public void setPattern(Pattern pattern) {
        this.pattern = pattern;
    }

    public Map<String, Integer> getParamIndexMapping() {
        return paramIndexMapping;
    }

    public void setParamIndexMapping(Map<String, Integer> paramIndexMapping) {
        this.paramIndexMapping = paramIndexMapping;
    }
}
